﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AdmBase;
using Guedes_Library;

public partial class admin_pages_clientes_Default : TelaBase
{

    private ClienteBusiness clienteBusiness;

    public ClienteBusiness ClienteBusiness
    {
        get
        {
            if (clienteBusiness == null)
                clienteBusiness = new ClienteBusiness();
            return clienteBusiness;
        }
        set { clienteBusiness = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        IsLogado();
    }

    protected void SelectGrid(object sender, EventArgs e)
    {
        GridView grid = (GridView)sender;
        Response.Redirect("~/admin/pages/clientes/Novo.aspx?id=" + grid.SelectedValue.ToString());
    }

    protected void Deletar(object sender, EventArgs e)
    {
        int id = int.Parse(((LinkButton)sender).CommandName);

            clients p = ClienteBusiness.GetById(id);
            string url = p.Image;
            String msg = ClienteBusiness.Deletar(id);
            if (msg != "")
                ApagarArquivo(url);
        DataBind();
        GridViewCliente.DataBind();
        ShowMensagem("Atenção", msg);
    }
}